using System;
using System.Collections;
using System.DirectoryServices;

namespace BEGDC.CC.Entity
{
    #region VehicleBooking

    /// <summary>
    /// VehicleBooking object for NHibernate mapped table 'VehicleBooking'.
    /// </summary>
    [Serializable]
    public class VehicleBooking : System.IComparable
    {
        #region Member Variables

        protected int _id;
        protected int _vehicleNumber;
        protected decimal _price;
        protected string _otherVehicle;
        protected VehicleType _vehicleType;
        protected LogisticalInfo _logisticalInfo;
        protected static String _sortExpression = "Id";
        protected static SortDirection _sortDirection = SortDirection.Ascending;

        #endregion

        #region Constructors

        public VehicleBooking() { }

        public VehicleBooking(int vehicleNumber, decimal price, VehicleType vehicleType, LogisticalInfo logisticalInfo, string otherVehicle)
        {
            this._vehicleNumber = vehicleNumber;
            this._price = price;
            this._otherVehicle = otherVehicle;
            this._vehicleType = vehicleType;
            this._logisticalInfo = logisticalInfo;
        }

        #endregion

        #region Public Properties

        public int Id
        {
            get { return _id; }
            set { _id = value; }
        }

        public int VehicleNumber
        {
            get { return _vehicleNumber; }
            set { _vehicleNumber = value; }
        }

        public decimal Price
        {
            get { return _price; }
            set { _price = value; }
        }

        public string OtherVehicle
        {
            get { return _otherVehicle; }
            set { _otherVehicle = value; }
        }

        public VehicleType VehicleType
        {
            get { return _vehicleType; }
            set { _vehicleType = value; }
        }

        public LogisticalInfo LogisticalInfo
        {
            get { return _logisticalInfo; }
            set { _logisticalInfo = value; }
        }

        public static String SortExpression
        {
            get { return _sortExpression; }
            set { _sortExpression = value; }
        }

        public static SortDirection SortDirection
        {
            get { return _sortDirection; }
            set { _sortDirection = value; }
        }
        #endregion

        #region IComparable Methods
        public int CompareTo(object obj)
        {
            if (!(obj is VehicleBooking))
                throw new InvalidCastException("This object is not of type VehicleBooking");

            int relativeValue;
            switch (SortExpression)
            {
                case "Id":
                    relativeValue = this.Id.CompareTo(((VehicleBooking)obj).Id);
                    break;
                case "VehicleNumber":
                    relativeValue = this.VehicleNumber.CompareTo(((VehicleBooking)obj).VehicleNumber);
                    break;
                case "Price":
                    relativeValue = this.Price.CompareTo(((VehicleBooking)obj).Price);
                    break;
                case "OtherVehicle":
                    relativeValue = this.OtherVehicle.CompareTo(((VehicleBooking)obj).OtherVehicle);
                    break;
                default:
                    goto case "Id";
            }
            if (VehicleBooking.SortDirection == SortDirection.Ascending)
                relativeValue *= -1;
            return relativeValue;
        }
        #endregion
    }

    #endregion
}
